import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic

Item {
    width: parent.width
    height: parent.height

    Button {
        x: 50
        y: 50
        text: "Show Animated Popup"
        onClicked: animatedPopup.open()
    }

    Popup {
        id: animatedPopup
        x: 50
        y: 90
        width: 300
        height: 200
        modal: true
        focus: true

        enter: Transition {
            NumberAnimation { 
                property: "opacity"
                from: 0.0
                to: 1.0
                duration: 300
            }
            NumberAnimation {
                property: "scale"
                from: 0.5
                to: 1.0
                duration: 300
            }
        }

        exit: Transition {
            NumberAnimation { 
                property: "opacity"
                from: 1.0
                to: 0.0
                duration: 300
            }
            NumberAnimation {
                property: "scale"
                from: 1.0
                to: 0.5
                duration: 300
            }
        }

        background: Rectangle {
            color: "#f0f0f0"
            border.color: "#4CAF50"
            border.width: 2
            radius: 10
        }

        Column {
            anchors.centerIn: parent
            spacing: 15

            Label {
                text: "Animated Popup"
                font.pixelSize: 18
                font.bold: true
                color: "#4CAF50"
            }

            Text {
                text: "This popup has:\n• Fade in/out animation\n• Scale animation\n• Smooth transitions"
                color: "#333"
                font.pixelSize: 14
            }

            Button {
                text: "Close"
                onClicked: animatedPopup.close()
                background: Rectangle {
                    color: "#4CAF50"
                    radius: 5
                }
                contentItem: Text {
                    text: parent.text
                    color: "white"
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                }
            }
        }
    }
}
